package j2src;

import java.util.Vector;
import beans.EmpInformationDaoRemote;
import beans.EmpInformationDto;
import beans.EmpInformationHome;

public class EmpInformationDaoDelegate {
    private EmpInformationHome empInformationHome;
    private EmpInformationDaoRemote empInformationDaoRemote;
    public EmpInformationDaoDelegate() throws Exception {
        initializeEmpInformationDaoHome();
        empInformationDaoRemote = empInformationHome.create();
    }
    
    public Vector getAllEmployees() throws Exception{
    	return empInformationDaoRemote.getAllEmployees();
    }
	public EmpInformationDto getOneEmployee(String empId) throws Exception{
		return empInformationDaoRemote.getOneEmployee(empId);
	}
	public boolean insertEmployee(EmpInformationDto eDto) throws Exception{
		return empInformationDaoRemote.insertEmployee(eDto);
	}
	public boolean updateEmployee(EmpInformationDto eDto) throws Exception{
		return empInformationDaoRemote.updateEmployee(eDto);
	}
	public boolean deleteEmployee(String empId) throws Exception{
		return empInformationDaoRemote.deleteEmployee(empId);
	}   
    private void initializeEmpInformationDaoHome() throws Exception {
        String FACADE_NAME = "EmpInformationDaoBean";
        Class FACADE_CLASS = beans.EmpInformationHome.class;
        if (empInformationHome == null) {
            try {
                WhiteDaoLocator locator = WhiteDaoLocator.getInstance();
                empInformationHome = (EmpInformationHome) WhiteDaoLocator.getEjbHome(FACADE_NAME, FACADE_CLASS);
                if (empInformationHome == null) {
                    throw new Exception("Did not get home for " + FACADE_NAME);
                }
            } catch (WhiteDaoLocatorException e) {
                throw new Exception(e.getMessage());
            }
        }
    }
}
